package com.gemme.gemme.wode;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.gemme.gemme.BaseActivity;
import com.gemme.gemme.R;
import com.gemme.gemme.view.OnChangeLIstener;
import com.gemme.gemme.view.PayDialog;
import com.gemme.gemme.view.RoundCheckBox;
import com.gemme.gemme.view.Topview;
import com.gemme.gemme.view.VipSgView;
import com.jaeger.library.StatusBarUtil;

//侧滑删除地址
public class Vip2Activity extends BaseActivity{
    int status = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vip2);
        StatusBarUtil.setTransparent(this);
        initView();
    }


    VipSgView vipSgView1;
    VipSgView vipSgView2;
    public  int type = TYPE_ZHUANSHU;
    public static final int TYPE_ZHUANSHU = 1;
    public static final int TYPE_TIYAN = 2;
    TextView tv_price_real;
    boolean isVip = false;
    private void initView() {
        vipSgView1 = findViewById(R.id.vipSgView1);
        vipSgView2 = findViewById(R.id.vipSgView2);
        tv_price_real = findViewById(R.id.tv_price_real);
        vipSgView1.setPrice("288");
        vipSgView2.setPrice("28");
//        changeState();
        controlSelect();
        initIsVipView();

        tv_price_real.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new PayDialog().showDialog(mContext);
            }
        });
    }

    private void controlSelect() {
        RoundCheckBox cbox1 = vipSgView1.getCbox();
        RoundCheckBox cbox2 = vipSgView2.getCbox();
        cbox1.setOnChangeLIstener(new OnChangeLIstener() {
            @Override
            public void onChangeLIstener() {
                boolean checked = cbox1.isChecked();
                vipSgView1.setIsCheck( cbox1.isChecked());
                if(checked){
                    type = TYPE_ZHUANSHU;
                }

                changeState();
            }
        });

        cbox2.setOnChangeLIstener(new OnChangeLIstener() {
            @Override
            public void onChangeLIstener() {
                boolean checked = cbox2.isChecked();
                vipSgView2.setIsCheck(checked);
                if(checked){
                    type = TYPE_TIYAN;
                }
                changeState();

            }
        });

    }

    private void initIsVipView() {
        View vip_no = findViewById(R.id.vip_no);
        View vip_yes = findViewById(R.id.vip_yes);
        if(isVip){
            vip_yes.setVisibility(View.VISIBLE);
            vip_no.setVisibility(View.GONE);
        }else{
            vip_yes.setVisibility(View.GONE);
            vip_no.setVisibility(View.VISIBLE);
        }

    }

    private void changeState() {
        switch (type){
            case TYPE_ZHUANSHU:
                vipSgView2.setSatate(false);
//                new PayDialog().showDialog(mContext);
                tv_price_real.setText("288");
                break;

            case TYPE_TIYAN:
                vipSgView1.setSatate(false);
//                new PayDialog().showDialog(mContext);
                tv_price_real.setText("28");
                break;
        }
    }


}